//package com.macro.mall.portal.task;
//
//
//import com.macro.mall.portal.dao.DataTotalMapper;
//import com.macro.mall.portal.dao.LoanPlanMapper;
//import com.macro.mall.portal.dao.PartnerMapper;
//import com.macro.mall.portal.dao.UserRollMapper;
//import com.macro.mall.portal.domain.DataTotal;
//import com.macro.mall.portal.domain.LoanPlan;
//import com.macro.mall.portal.domain.Partner;
//import com.macro.mall.portal.domain.UserRoll;
//import com.macro.mall.portal.domain.vo.WxMsgVo;
//import com.macro.mall.portal.util.ConfigConstant;
//import com.macro.mall.portal.util.WxMsgPush;
//import lombok.RequiredArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.scheduling.annotation.EnableScheduling;
//import org.springframework.scheduling.annotation.Scheduled;
//
//import java.time.LocalDateTime;
//import java.time.format.DateTimeFormatter;
//import java.util.List;
//
///**
// * @CreateTime: 2021-6-28 09:35
// * @Description: 定时统计
// */
//@Slf4j
//@Configuration
//@EnableScheduling
//@RequiredArgsConstructor(onConstructor_ = @Autowired)
//public class CalculationTask {
//
//    @Autowired
//    private WxMsgPush wxMsgPush;
//
//    @Autowired
//    private PartnerMapper partnerMapper;
//
//    @Autowired
//    private LoanPlanMapper loanPlanMapper;
//
//    @Autowired
//    private UserRollMapper userRollMapper;
//
//    @Autowired
//    private DataTotalMapper dataTotalMapper;
//
//
//    /**
//     * 使用 cron 表达式,每隔5秒执行一次
//     */
//    @Scheduled(cron = "0 30 8 * * ?")
//    public void taskTwo() {
//        //时间
//        LocalDateTime time = LocalDateTime.now();
//        DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
//        String now = dtf2.format(time);
//        //佣金券
//        List<UserRoll> rollList = userRollMapper.getAll();
//        List<Partner> partnerList = partnerMapper.getAll();
//        List<LoanPlan> planList = loanPlanMapper.getAll();
//        int total = rollList.size() + partnerList.size() + planList.size();
//        DataTotal dataTotal = DataTotal.builder()
//                .mea(planList.size())
//                .roll(rollList.size())
//                .partner(partnerList.size())
//                .lastDay(total)
//                .openId(ConfigConstant.YANG_OPEN)
//                .build();
//        dataTotalMapper.insert(dataTotal);
//        //发送消息模板
//        String url = ConfigConstant.TJ_URL + "?id=" + dataTotal.getId();
//        WxMsgVo msgVo = WxMsgVo.builder()
//                .first("早上好！咋日数据统计待查看")
//                .keyword1("点击查看详情")
//                .keyword2(now)
//                .openId(ConfigConstant.D_OPEN)
//                .url(url)
//                .remark("佣金券新增:" + rollList.size() + "测额新增:" + planList.size() + "合伙人:" + partnerList.size() + "昨天新增:" + total)
//                .build();
//        wxMsgPush.SendWxMsg(msgVo);
//    }
//
//
//}
//
//
